﻿using System;
using GdNet.Integrations.NHibernate.Assistants;
using GdNet.Integrations.NHibernate.Mapping;
using GdNet.WebFramework.Domain.System;
using NHibernate.Mapping.ByCode;

namespace GdNet.WebFramework.Mapping.System
{
    public class ModuleActionMapping : AbstractJoinedSubclassMapping<ModuleAction, Guid>, IEntityMapping
    {
        public ModuleActionMapping()
            : base()
        {
            base.Property(e => e.Code);
            base.Property(e => e.Name);
            base.Property(e => e.ClassName);
            base.Property(e => e.ViewName);

            base.ManyToOne(e => e.Module, m =>
                {
                    m.Lazy(LazyRelation.Proxy);
                    m.Access(Accessor.Property);
                    m.Column(MappingAssistant.GetForeignKeyColumn<ModuleAction, Module>(ma => ma.Module));
                });
        }
    }
}
